package com.ym.manager.yinsheng.controller;

import com.ym.manager.yinsheng.util.RequestData;
import com.ym.manager.yinsheng.util.ServiceEnum;
import com.ym.manager.yinsheng.util.YinShengClient;
import com.ym.utils.ResultUtil;
import com.ym.utils.StringHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: dhf
 * @ClassName: YinShengController
 * @Date: 2022/8/20 20:17
 * @Description:
 * @Version: 1.0
 */
@RequestMapping("/ys")
@RestController
public class YinShengController {


    @RequestMapping("/order/info")
    public String OrderInfo(){
        return "";
    }

    @RequestMapping("/order/status")
    public String OrderInfo(String order_sn){
        Map<String,Object> result = ResultUtil.result();
        Map<String,Object> requestMap = new HashMap<>();
        requestMap.put("requestNo",order_sn);
        RequestData requestData = new RequestData(requestMap);
        YinShengClient yinShengClient = new YinShengClient(ServiceEnum.QUERY_ORDER);
        Map<String, Object> map = yinShengClient.requestApi(requestData,"订单查询");
        if(StringHandler.isEmpty(map)){
            result.put("code","500");
            result.put("msg","订单查询失败");
        }
        if(StringHandler.getInt(map.get("code")+"")==0){
            result.put("data",map);
        }
        return ResultUtil.toJSON(result);
    }

}
